package com.tiantianyuegou.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.Toast;

import com.tiantianyuegou.activity.BaseActivity ;
import com.tiantianyuegou.R;
import com.tiantianyuegou.activity.StoreDetailActivity;
import com.tiantianyuegou.activity.StoreListActivity;
import com.tiantianyuegou.adapter.LocalStoreAdapter;
import com.tiantianyuegou.adapter.LocalStoreModularGridAdapter;
import com.tiantianyuegou.adapter.TuangouHottingAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/1/13.
 */
public class TuangouNewingFragment extends Fragment {
    View rootView;
    BaseActivity activity;
    ListView mListView;

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        activity = (BaseActivity) getActivity();
        if (rootView == null) {
            rootView = inflater.inflate(R.layout.fragment_tuangouhoting, container,
                    false);
        }
        ViewGroup parent = (ViewGroup) rootView.getParent();
        if (parent != null) {
            parent.removeView(rootView);
        }
        findViewByIds();
        ininListener();
        return rootView;
    }

    public void findViewByIds() {

        mListView=(ListView)rootView.findViewById(R.id.list_tuanhoting);
    }

    public void ininListener() {
//        mListView.setAdapter(new TuangouHottingAdapter(getActivity()));

        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Toast.makeText(getActivity(), "商品" + i, Toast.LENGTH_SHORT).show();
//                Intent intent=new Intent(activity, StoreDetailActivity.class);
//                startActivity(intent);
            }
        });
    }
}
